<%= page_title "Kubernetes Cluster #{@kubernetes_cluster.name}" %>

<section class="form-horizontal">
  <div class="form-group">
    <label class="col-lg-2 control-label">Name</label>
    <div class="col-lg-4">
      <p class="form-control-static"><%= @kubernetes_cluster.name %></p>
    </div>
  </div>

  <div class="form-group">
    <label class="col-lg-2 control-label">Description</label>
    <div class="col-lg-4">
      <p class="form-control-static"><%= @kubernetes_cluster.description %></p>
    </div>
  </div>

  <% if ENV["KRITIS_BREAKGLASS_SUPPORTED"] %>
  <div class="form-group">
    <label class="col-lg-2 control-label">
      Kritis Breakglass
    </label>
    <div class="col-lg-4">
      <p class="form-control-static"><%= @kubernetes_cluster.kritis_breakglass ? "YES" : "NO" %></p>
    </div>
  </div>
  <% end %>

  <% case @kubernetes_cluster.auth_method %>
  <% when "context" %>
    <div class="form-group">
      <label class="col-lg-2 control-label">Context</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.config_context %></p>
      </div>
    </div>

    <div class="form-group">
      <label class="col-lg-2 control-label">Config filepath</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.config_filepath %></p>
      </div>
    </div>

    <div class="form-group">
      <label class="col-lg-2 control-label">URL</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.client('v1').api_endpoint rescue "Error finding api endpoint: #{$!}" %></p>
      </div>
    </div>
  <% when "database" %>
    <div class="form-group">
      <label class="col-lg-2 control-label">URL</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.api_endpoint %></p>
      </div>
    </div>

    <div class="form-group">
      <label class="col-lg-2 control-label">Client Cert</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.client_cert? ? "YES" : "NO" %></p>
      </div>
    </div>

    <div class="form-group">
      <label class="col-lg-2 control-label">Client Key</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.client_key? ? "YES" : "NO" %></p>
      </div>
    </div>

    <div class="form-group">
      <label class="col-lg-2 control-label">Verify SSL</label>
      <div class="col-lg-4">
        <p class="form-control-static"><%= @kubernetes_cluster.verify_ssl? ? "YES" : "NO" %></p>
      </div>
    </div>
  <% else %>
    Unsupported auth method
  <% end %>

  <div class="form-group">
    <label class="col-lg-2 control-label">Deploy Groups</label>
    <div class="col-lg-4">
      <p class="form-control-static">
        <%= render 'deploy_group_list', deploy_groups: @kubernetes_cluster.deploy_groups %>
      </p>
    </div>
  </div>

  <div class="form-group">
    <div class="col-lg-offset-2 col-lg-10">
      <%= link_to "Edit", edit_kubernetes_cluster_path(@kubernetes_cluster), class: "btn btn-primary" %>
      <%= link_to "Back", kubernetes_clusters_path, class: "btn btn-default" %>
    </div>
  </div>
</section>
